<template>
  <div class="login">
    <div style="padding: 20px">
      <el-row :gutter="10">
        <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
          <el-form
            ref="loginForm"
            :model="loginForm"
            :rules="loginRules"
            class="login-form"
          >
            <h3 class="title" v-if="!bindAccount">账号登录</h3>
            <h3 class="bindAccountTitle" v-else>绑定物美智能账户</h3>
            <el-form-item prop="username">
              <el-input
                v-model="loginForm.username"
                type="text"
                auto-complete="off"
                placeholder="账号"
              >
                <svg-icon slot="prefix" icon-class="user" class="input-icon" />
              </el-input>
            </el-form-item>
            <el-form-item prop="password">
              <el-input
                v-model="loginForm.password"
                type="password"
                auto-complete="off"
                placeholder="密码"
                @keyup.enter.native="handleLogin"
              >
                <svg-icon
                  slot="prefix"
                  icon-class="password"
                  class="input-icon"
                />
              </el-input>
            </el-form-item>
            <el-form-item prop="code" v-if="captchaOnOff">
              <el-input
                v-model="loginForm.code"
                auto-complete="off"
                placeholder="验证码"
                style="width: 63%"
                @keyup.enter.native="handleLogin"
              >
                <svg-icon
                  slot="prefix"
                  icon-class="validCode"
                  class="input-icon"
                />
              </el-input>
              <div class="login-code">
                <img :src="codeUrl" @click="getCode" />
              </div>
            </el-form-item>
            <el-checkbox
              v-model="loginForm.rememberMe"
              style="margin: 0px 0px 25px 0px; color: #000"
              >记住密码</el-checkbox
            >
            <el-form-item style="width: 100%">
              <el-button
                v-if="!bindAccount"
                :loading="loading"
                type="primary"
                style="width: 100%"
                @click.native.prevent="handleLogin"
              >
                <span v-if="!loading">登 录</span>
                <span v-else>登 录 中...</span>
              </el-button>
              <el-button
                v-else
                :loading="loading"
                type="primary"
                style="width: 100%"
                @click.native.prevent="handleLogin"
              >
                <span v-if="!loading">绑定</span>
                <span v-else>绑 定 中...</span>
              </el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <!--  底部  -->
    <div class="el-login-footer">
      <span
        >Copyright © 2018-2021
        <a target="_blank" href="http://wumei.live">wumei smart</a> All Rights
        Reserved.</span
      >
    </div>
  </div>
</template>

<script>
  import { defineComponent } from '@vue/composition-api'

  export default defineComponent({
    setup() {}
  })
</script>
<style lang="scss" scoped>
  .login {
    background: linear-gradient(303deg, #48c6ef 10%, #6f86d6 80%);
    height: 100%;
    overflow: auto;
    padding-top: 150px;
  }
  .title {
    margin: 0px auto 20px auto;
    text-align: center;
    color: #333;
    font-size: 28px;
  }
  .bindAccountTitle {
    margin: 0px auto 30px auto;
    text-align: center;
    color: #333;
    font-size: 24px;
  }
  .login-top {
    color: #fff;
    text-align: center;
    @media screen and (min-width: 992px) {
      h1 {
        font-size: 36px;
      }
      h2 {
        font-size: 20px;
        margin-top: -20px;
      }
    }
    @media screen and (min-width: 1200px) {
      h1 {
        font-size: 46px;
      }
      h2 {
        font-size: 26px;
        margin-top: -25px;
      }
    }
    @media screen and (min-width: 1920px) {
      padding: 0px;
      h1 {
        font-size: 62px;
      }
      h2 {
        font-size: 35px;
        margin-top: -30px;
      }
    }
  }
  .login-form {
    box-shadow: 0 20px 30px 0 rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background-color: rgba(250, 250, 250, 0.8);
    border: 1px solid #fff;
    padding: 25px 25px 5px 25px;
    margin: 0 auto;
    z-index: 1000;
    max-width: 370px;
    margin-bottom: 100px;
    .el-input {
      height: 38px;
      input {
        height: 38px;
        background-color: rgba(0, 0, 0, 0.1);
        color: #333;
      }
      // 谷歌
      input::-webkit-input-placeholder {
        color: #666;
      }
      // 火狐19+版本
      input::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #666;
      }
      // 火狐4-18版本
      input:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #666;
      }
      // IE10-11版本
      input:-ms-input-placeholder {
        /* Internet Explorer 10-11 */
        color: #666;
      }
    }
    .input-icon {
      height: 39px;
      width: 14px;
      margin-left: 2px;
      color: #fff;
    }
  }
  .login-code {
    width: 33%;
    height: 38px;
    float: right;
    img {
      cursor: pointer;
      vertical-align: middle;
      border-radius: 5px;
      height: 38px;
    }
  }
  .el-login-footer {
    height: 40px;
    line-height: 40px;
    position: fixed;
    bottom: 0;
    width: 100%;
    text-align: center;
    color: #fff;
    font-family: Arial;
    font-size: 12px;
    letter-spacing: 1px;
  }
</style>
